<?php
class CodeSpace_Oauth_Server_Service extends CodeSpace_Oauth_Server
{
    private $_dataPath = null;
    private $_nonceWindow = null;
    
    public function __construct($options = null)
    {
        parent::__construct($options);
    }
    
    public function setRequest()
    {
        $this->_requestType = self::REQUEST_SERVICE;
        $this->_request = new CodeSpace_Oauth_Server_Request_Service();
    }
    
    public function setNonceWindow($time)
    {
        $this->_nonceWindow = $time;
    }
    
    public function getNonceWindow()
    {
        return $this->_nonceWindow;
    }
    
    public function setDataPath($path)
    {
        $this->_dataPath = $path;
    }
    
    public function getDataPath()
    {
        return $this->_dataPath;
    }
    
    private function _hasNonce($nonce)
    {
        // Find the file that has name $nonce
    }
    
    private function _isInWindow($file)
    {
        // checks the given file is in window rate
        return true;
    }
    
    protected function _checkOauthRequest ()
    {
        // Check for NONCE and TIMESTAMP
        $nonce = $this->getNonce();
        $timestamp = $this->getTimestamp();
        
        if($this->_hasNonce($nonce))
        {
            $file = fopen($this->_dataPath . "/" . $nonce . ".xml", $mode);
            $xml = simplexml_load_string($file);
            //fclose($file);
            if($this->_isInWindow($file))
            {
                // ERROR
                // do not delete file
                return false;
            }else 
            {
                // Delete File
                unlink($file);
                // Accept Request
                return true;
            }
        }else
        {
            // Accept Request
            return true;
        }
        
        
    }
}
?>